package cn.itrip.commons;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author Super God Jie
 * @version 1.0  2022-04-15 09:37
 */
@NoArgsConstructor
@Data
public class Page<T> {
	private Integer beginPos;
	private Integer curPage =1;
	private Integer pageCount;
	private Integer pageSize = 6;
	private Integer total;
	private List<T> rows;

	public Page(Integer curPage,Integer total,Integer pageSize) {
		if(total>0){
			this.curPage = curPage;
			this.total = total;
			this.pageSize = pageSize;
			this.curPage = curPage == null ? 1 : curPage;
			this.pageCount = (total + this.pageSize - 1) / this.pageSize;
			if (this.curPage > this.pageCount) {
				this.curPage = this.pageCount;
			}
			this.beginPos = (curPage - 1) * this.pageSize;
		}
	}
}
